package com.baidu.health.controller;

import com.baidu.health.pojo.TbTask;
import com.baidu.health.pojo.TbTaskSituation;
import com.baidu.health.service.OssService;
import com.baidu.health.service.TbTaskService;
import com.baidu.health.service.TbTaskSituationService;
import com.baidu.health.util.resFaqVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Api(tags = "任务中心")
@RestController
@RequestMapping("task")
public class TbTaskController {
    @Autowired
    TbTaskService tbTaskService;

    @Autowired
    private OssService ossService;

    @Autowired
    private TbTaskSituationService tbTaskSituationService;

    /**
     * 提交图片
     * @param file
     * @return
     */
    @RequestMapping("/upload")
    public Object upload(@PathVariable("file") MultipartFile file){
        return ossService.upload(file);
    }

    //任务查询
    @RequestMapping("list")
    private List<TbTask> list1(){
        return tbTaskService.list1();
    }

    //任务添加
    @PostMapping("taskAdd")
    private resFaqVo taseAdd(@RequestBody TbTask tbTaskadd){
        return tbTaskService.taskAdd(tbTaskadd);
    }

    //任务删除
//    @PostMapping("taskDelete/{tid}")
//    private void taskDeleteByTid(@PathVariable Integer tid){
//        tbTaskService.taskDeleteByTid(tid);
//    }
    @PostMapping("taskDelete")
    private resFaqVo taskDeleteByTaskid(@RequestBody TbTask tbTaskd){
        return tbTaskService.taskDeleteByTaskid(tbTaskd);
    }

    //任务分页
    @PostMapping("taskPage")
    private resFaqVo taskAll(@RequestBody TbTask tbTaskPage){
        return tbTaskService.selectPage(tbTaskPage);
    }

    //添加完成情况
    @PostMapping("taskSituation")
    private resFaqVo taskSituation(@RequestBody TbTaskSituation tbTaskSituation){
        return tbTaskSituationService.taskSituation(tbTaskSituation);
    }
    //查看完成情况，没完成添加未完成 （每天凌晨执行）
    @PostMapping("taskSituations")
    private resFaqVo taskSituations(@RequestBody TbTaskSituation tbTaskSituation){
        return tbTaskSituationService.taskSituations(tbTaskSituation);
    }

    @PostMapping("taskSituationsList")
    private resFaqVo taskSituationsList(@RequestBody TbTaskSituation tbTaskSituationlist){
        return tbTaskSituationService.taskSituationsList(tbTaskSituationlist);
    }
}
